<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>详情</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/me.css">
    <link rel="stylesheet" href="../static/css/typo.css">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" href="../static/css/animate.css">

</head>
<body>

<!--导航-->
    <nav th:replace="_fragments :: menu(1)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small">
        <div class="ui container">
          <div class=" ui inverted  secondary stackable menu">
              <h2 class="ui teal header item ">自学论坛系统</h2>
              <a href="#" class="m-item item ui inverted red basic button m-mobile-hide"><i class="small globe icon"></i>首页</a>
              <a href="#" class="m-item item ui inverted orange basic button m-mobile-hide"><i class="small idea icon"></i>分类</a>
              <a href="#" class="m-item item ui inverted yellow basic button m-mobile-hide"><i class="small tags icon"></i>标签</a>
              <a href="#" class="m-item item ui inverted purple basic button m-mobile-hide"><i class="small clone icon"></i>归档</a>
              <a href="#" class="m-item item ui inverted olive basic button m-mobile-hide"><i class="small info icon"></i>关于我</a>
              <div class="m-item right item m-mobile-hide">
                  <div class="ui icon transition input">
                      <input type="text" placeholder="搜索...">
                      <i class="search link icon"></i>
                  </div>
              </div>
          </div>
        </div>
        <a href="#" class="ui menu toggle icon black button m-right-top m-mobile-show">
            <i class="list ui icon"></i>
        </a>

    </nav>


<!--中间内容-->
    <div id="waypoint" class="m-padded-tb-large m-container-small animated zoomIn main-content">
        <div class="ui container">
            <div class="ui top attached segment">
                <div class="ui horizontal link list">
                    <div class="item">
                        <img src="../static/images/The%20Stone%20Roses.jpg"  th:src="@{${blog.user.avatar}}" alt="" class="ui avatar image">
                        <div class="content"><a href="#" class="header" th:text="${blog.user.nickname}">The Stone Roses</a></div>
                    </div>
                    <div class="item">
                        <i class="calendar alternate icon"></i><span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2021-1-1</span>
                    </div>
                    <div class="item">
                        <i class="eye icon"></i><span th:text="${blog.views}">1234</span>
                    </div>
                </div>
            </div>
            <div class="ui attached segment">
                <!--pic-->
                <img src="../static/images/The%20Stone%20Roses.jpg" th:src="@{${blog.firstPicture}}" alt="" class="ui fluid rounded image">
            </div>
            <!--main-->
            <div class="ui  attached padded segment">
                <div class="ui right aligned basic segment">
                    <div class="ui orange label basic" th:text="${blog.flag}">原创</div>
                </div>
                <h2 class="ui center aligned header" th:text="${blog.title}">The Stone Roses简介</h2>
                <br>
                <div id="content" class="typo typo-selection js-toc-content m-padded-lr-responsive m-padded-tb-large" th:utext="${blog.content}">
                    <p>80年代末期英国流行音乐进入低潮，曾创造英国新浪潮音乐的曼彻斯特，这期间也变得萧条。正当英国音乐将在沉闷中进入90年代的时候，一支叫做“石玫瑰”(The Stone Roses)的乐队出现了，1989年，他们的第一张专辑的出版，使英国“独立摇滚”(Indie-Rock)现象进入了新的时代。</p>
                </div>
                <!--label-->
                <div class="m-padded-lr-responsive">
                    <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">英伦摇滚</div>
                </div>
                <!--赞赏-->
                <div th:if="${blog.appreciation}">
                    <div class="ui segment center aligned basic">
                        <button id="zs" class="ui orange basic circular button">赞赏</button>
                    </div>
                    <div class="ui zsq flowing popup transition hidden">
                        <div class="ui orange basic label">
                            <div class="ui images">
                                <div class="image">
                                    <img src="../static/images/ewm.jpg" th:src="@{/images/ewm.jpg}" alt="" class="ui rounded bordered image" style="width: 120px">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--message-->
            <div class="ui attached positive message" th:if="${blog.shareStatement}">
                <div class="ui middle aligned grid">
                    <div class="eleven wide column">
                        <div class="list">
                            <li>作者：<span th:text="${blog.user.nickname}">cl</span><a href="#" th:href="@{/about}" target="_blank">（联系作者）</a></li>
                            <li>发表时间：<span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}">2021-1-17 09:08</span></li>
                            <li>版权声明：自由转载-非商用-非衍生-保持署名（创意共享3.0许可证）</li>
                            <li>公众号转载：请在文末添加作者公众号二维码</li>
                        </div>
                    </div>
                    <div class="five wide column">
                        <img src="../static/images/ewm.jpg" th:src="@{/images/ewm.jpg}" alt="" class="ui right floated rounded bordered image" style="width: 140px">
                    </div>
                </div>
            </div>
            <!--comment-->
            <div class="ui bottom attached segment" th:if="${blog.commentabled}">
                <!--留言列表-->
                <div id="comment-container"  class="ui teal segment">
                    <div th:fragment="commentList">
                        <div class="ui comments" style="max-width: 100%;">
                            <h3 class="ui dividing header">评论</h3>
                            <div class="comment" th:each="comment : ${comments}">
                                <a class="avatar">
                                    <img  src="../static/images/tsdr1.jpg" th:src="@{${comment.avatar}}">
                                </a>
                                <div class="content">
                                    <a class="author" >
                                        <span th:text="${comment.nickname}">Matt</span>
                                        <div class="ui mini basic teal left pointing label m-padded-mini m-text-thin" th:if="${comment.adminComment}">博主</div>
                                    </a>
                                    <div class="metadata">
                                        <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                    </div>
                                    <div class="text" th:text="${comment.content}">
                                        How artistic!
                                    </div>
                                    <div class="actions">
                                        <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>
                                    </div>
                                </div>
                                <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                    <div class="comment" th:each="reply : ${comment.replyComments}">
                                        <a class="avatar">
                                            <img src="../static/images/tsdr1.jpg" th:src="@{${reply.avatar}}">
                                        </a>
                                        <div class="content">
                                            <a class="author" >
                                                <span th:text="${reply.nickname}">小红</span>
                                                <div class="ui mini basic teal left pointing label m-padded-mini m-text-thin" th:if="${reply.adminComment}">博主</div>
                                                &nbsp;<span th:text="|@ ${reply.parentComment.nickname}|" class="m-teal">@ 小白</span>
                                            </a>
                                            <div class="metadata">
                                                <span class="date" th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                            </div>
                                            <div class="text" th:text="${reply.content}">
                                                How artistic!
                                            </div>
                                            <div class="actions">
                                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}" onclick="reply(this)">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--/*-->
                            <div class="comment">
                                <a class="avatar">
                                    <img src="https://unsplash.it/100/100?image=1005">
                                </a>
                                <div class="content">
                                    <a class="author">Elliot Fu</a>
                                    <div class="metadata">
                                        <span class="date">Yesterday at 12:30AM</span>
                                    </div>
                                    <div class="text">
                                        <p>This has been very useful for my research. Thanks as well!</p>
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                                <div class="comments">
                                    <div class="comment">
                                        <a class="avatar">
                                            <img src="https://unsplash.it/100/100?image=1005">
                                        </a>
                                        <div class="content">
                                            <a class="author">Jenny Hess</a>
                                            <div class="metadata">
                                                <span class="date">Just now</span>
                                            </div>
                                            <div class="text">
                                                Elliot you are always so right :)
                                            </div>
                                            <div class="actions">
                                                <a class="reply">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="comment">
                                <a class="avatar">
                                    <img src="https://unsplash.it/100/100?image=1005">
                                </a>
                                <div class="content">
                                    <a class="author">Joe Henderson</a>
                                    <div class="metadata">
                                        <span class="date">5 days ago</span>
                                    </div>
                                    <div class="text">
                                        Dude, this is awesome. Thanks so much
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                            </div>
                            <!--*/-->

                        </div>
                    </div>
                </div>
                <!--评论-->
                <div id="comment-form" class="ui form">
                    <input type="hidden" name="blog.id" th:value="${blog.id}">
                    <input type="hidden" name="parentComment.id" value="-1">
                    <div class="field">
                        <textarea name="content" placeholder="请输入评论信息..."></textarea>
                    </div>
                    <div class="fields">
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="nickname" placeholder="姓名" th:value="${session.user}!=null ? ${session.user.nickname}">
                            </div>
                        </div>
                        <div class="field m-mobile-wide m-margin-bottom-small">
                            <div class="ui left icon input">
                                <i class="mail icon"></i>
                                <input type="text" name="email" placeholder="邮箱" th:value="${session.user}!=null ? ${session.user.email}">
                            </div>
                        </div>
                        <div class="field  m-margin-bottom-small m-mobile-wide">
                            <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide"><i class="edit icon"></i>发布</button>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

<!--右下导航-->
    <div id="toolbar" class="m-padded-tb-large m-fixed m-right-bottom" style="display:none">
        <div class="ui vertical icon buttons">
            <button type="button" class="ui toc teal button">目录</button>
            <a href="#comment-container" class="ui teal button">评论</a>
            <button class="ui wx icon button"><i class="wechat icon"></i></button>
            <div id="toTop-button" class="ui icon button"><i class="chevron up icon"></i></div>
        </div>
    </div>
<!--標題内容顯示-->
    <div class="ui toc-container flowing popup transition hidden" style="width: 200px!important;">
        <ol class="js-toc">
        </ol>
    </div>
<!--二维码-->
    <div id="qrcode" class="ui wx-qr flowing popup transition hidden" style="width: 165px !important;">
    <img src="./static/images/ewm.jpg" th:src="@{/images/ewm.jpg}" alt="" class="ui rounded image" style="width: 180px!important;">
    </div>
<!--底部-->
<footer th:replace="_fragments :: footer"  class="ui inverted vertical segment m-padded-tb-max">
    <div class="ui center aligned container">
        <div class="ui inverted divided stackable grid">
            <div class="two wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../static/images/lemon.png" th:src="@{images/lemon.png}" class="ui rounded image" alt="" style="width: 120px">
                    </div>
                </div>
            </div>
            <div class="four wide column">
                <h4 class="ui inverted header m-opacity-mini">最新帖子</h4>
                <div class="ui inverted link list m-text-spaced">


                </div>
            </div>
            <div class="four wide column">
                <h4 class="ui inverted header m-opacity-mini">联系我</h4>
                <div class="ui inverted link list m-text-spaced">
                    <a href="#" class="item"><i class="envelope outline icon"></i> email: 12138@nmsl.com</a>
                    <a href="#" class="item"><i class="comments outline icon"></i> vx: s14635123</a>
                    <a href="#" class="item"><i class="phone icon"></i> phone: 110</a>

                </div>
            </div>
            <div class="six wide column">
                <h4 class="ui inverted header m-opacity-mini">关于此论坛</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">暂无。。。</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-tiny"><i class="cn flag"></i>started in 2021.1.1 </p>
    </div>



</footer>


<!--/*/<th:block  th:replace="_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<!--平滑滚动-->
<script src="//cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script>
<script src="../static/lib/tocbot/tocbot.min.js"></script>
<script src="../static/lib/qrcode/qrcode.min.js"></script>
<script src="../static/lib/waypoints/jquery.waypoints.min.js"></script>
<!--/*/</th:block>/*/-->


<script th:inline="javascript">
// <!--jquery获取菜单 隐藏-->
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');

    });
    $('#zs').popup({
        popup: $('.zsq.popup'),
        on :'click',
        position:'bottom center'
    });

    $('.wx').popup({
        popup: $('.wx-qr'),
        position:'left center'
    });

    //初始化tocbot插件
    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
        // For headings inside relative or absolute positioned containers within content.
        hasInnerContainers: true,
    });

    $('.toc.button').popup({
        popup: $('.toc-container.popup'),
        on :'click',
        position:'left center'
    });
    var serurl = /*[[#{blog.serurl}]]*/"127.0.0.1:8080";
    var url = /*[[@{/blog/{id}(id=${blog.id})}]]*/"";
    //二维码生成
    var qrcode = new QRCode("qrcode", {
        text: "http://jindo.dev.naver.com/collie",
        width: 150,
        height: 150,
        colorDark : "#000000",
        colorLight : "#ffffff",
        correctLevel : QRCode.CorrectLevel.H
    });

    $('#toTop-button').click(function(){
        $(window).scrollTo(0,500);
    });

    //top隐藏导航 动画实现waypoint+animate css
    var waypoint = new Waypoint({
        element: document.getElementById('waypoint'),
        handler: function(direction) {
            if (direction == "down")
            {
                $('#toolbar').show().addClass('animated flipInX');
            }
            else
            {
                $('#toolbar').fadeOut();
            }
            console.log('Scrolled to waypoint!');
        }
    });

//评论表单验证
$('.ui.form').form({
    fields: {
        title: {
            identifier: 'content',
            rules: [{
                type: 'empty',
                prompt: '请输入评论内容'
            }
            ]
        },
        content: {
            identifier: 'nickname',
            rules: [{
                type: 'empty',
                prompt: '请输入你的大名'
            }]
        },
        type: {
            identifier: 'email',
            rules: [{
                type: 'email',
                prompt: '请填写正确的邮箱地址'
            }]
        }
    }
});

$(function () {
    $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/12");
});


$('#commentpost-btn').click(function () {
    var boo = $('.ui.form').form('validate form');
    if (boo) {
        console.log('校验成功');
        postData();
    } else {
        console.log('校验失败');
    }

});

function postData() {
    $("#comment-container").load(/*[[@{/comments}]]*/"",{
        "parentComment.id" : $("[name='parentComment.id']").val(),
        "blog.id" : $("[name='blog.id']").val(),
        "nickname": $("[name='nickname']").val(),
        "email"   : $("[name='email']").val(),
        "content" : $("[name='content']").val()
    },function (responseTxt, statusTxt, xhr) {
       // $(window).scrollTo($('#comment-container'),500);
        clearContent();
    });
}
function clearContent() {
    $("[name='content']").val('');
    $("[name='parentComment.id']").val(-1);
    $("[name='content']").attr("placeholder", "请输入评论信息...");
}

function reply(obj) {
    var commentId = $(obj).data('commentid');
    var commentNickname = $(obj).data('commentnickname');
    $("[name='content']").attr("placeholder", "@"+commentNickname).focus();
    $("[name='parentComment.id']").val(commentId);
    $(window).scrollTo($('#comment-form'),500);
}




</script>
</body>
</html>